<template>
  <div>
    <el-dialog
      :title="liulanchildren.trialTypeName"
      :visible.sync="dialogVisible"
      width="60%"
      center>
      <div>
        <div class="shangxia" >
          <el-form :model=zibaogaoform label-position="right" label-width="100">
              <div class="twobox" >
                <div class="texth">基本信息</div>
                <div  class="clearfix" style="padding: 10px;">
                  <el-col :span="8" v-for="(itemthree,indexthree) in formlist" :key="indexthree" >
                    <el-form-item :label="itemthree.trialProjectName" >
                      <el-input v-if="itemthree.dataType!=='2'&&itemthree.dataType!=='3'&&itemthree.dataType!=='4'" v-model="itemthree.value" :placeholder="`请输入${itemthree.trialProjectName}`" style="width: 100%;" size="small">
                        <span slot="suffix">{{ itemthree.unit }}</span>
                      </el-input>
                      <el-input v-else v-model="itemthree.convertValue" :placeholder="`请输入${itemthree.trialProjectName}`" style="width: 100%;" size="small">
                        <span slot="suffix">{{ itemthree.unit }}</span>
                      </el-input>
                    </el-form-item>
                  </el-col>
                </div>
                <div class="texth">试验数据</div>
                <div class="shiyanshuju">
                  <div class="header">
                    <div class="neirong">内容</div>
                    <div class="xiang">A相</div>
                    <div class="xiang">B相</div>
                    <div class="xiang">C相</div>
                  </div>
                  <div class="border" style="display: flex;">
                    <div class="bodyleft">
                      <div class="toop">
                        <div class="zuo">绝缘电阻测量示值（MΩ）</div>
                        <div class="you">
                          <div class="little">耐压前</div>
                          <div class="little">耐压后</div>
                        </div>
                      </div>
                      <div class="zhongjian">
                        <div class="jiaoliu">交流耐压试验</div>
                        <div class="time">
                          <div class="xiao">电压(KV)</div>
                          <div class="xiao">频率(HZ)</div>
                          <div class="xiao">时间(min)</div>
                        </div>
                      </div>
                      <div class="dibu">结果</div>
                    </div>
                    <div class="xunhuan" style="flex: 1;display: flex;flex-wrap: wrap;">
                      <div class="lillle" v-for="(item,index) in array" :key="index">{{ item.value }}</div>
                    </div>
                  </div>
                </div>
                <div class="foorterxunhuan">
                  <el-col :span="12" v-for="(item,index) in forterlist" :key="index">
                    <el-form-item :label="item.trialProjectName">
                      <el-input v-if="item.dataType!=='2'&&item.dataType!=='3'&&item.dataType!=='4'" v-model="item.value" style="width: 100%;" :placeholder="`请输入${item.trialProjectName}`"  size="small"></el-input>
                      <el-input v-else v-model="item.convertValue" style="width: 100%;" :placeholder="`请输入${item.trialProjectName}`"  size="small"></el-input>
                    </el-form-item>
                  </el-col>
                </div>
             </div>
          </el-form>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false" size="small" style="width: 60px;height: 30px;">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { getchushihuazibaogaoapi } from '@/api/Experimental-report/Main-information'
import {setlistsort} from '@/utils/array'
export default {
  name: 'CallPoliceChildrenCable',
  props: {
    liulanchildren: {
      type:Object
    },
    orgNo: {
      type:String
    }
  },
  data() {
    return {
      zibaogaoform:{},
      formlist:[],
      dialogVisible: false,
      array: [],
      forterlist:[]
    };
  },

  mounted() {
    
  },

  methods: {
    
  },
  watch: {
    async dialogVisible(val) {
      if (val) {
        const loading = this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        target: document.querySelector('.shangxia')
      });
        const { data: { list } } = await getchushihuazibaogaoapi({ id: this.liulanchildren.id, orgNo: this.orgNo, trialType: this.liulanchildren.trialType })
        this.formlist = list[0].children[0].children
        let arr1=[]
        for (let i = 0; i < list.length; i++){
          for (let j = 0; j < list[i].children.length; j++){
            for (let k = 0; k < list[i].children[j].children.length; k++) { 
               arr1.push(list[i].children[j].children[k])
            }
          }
        }
        const arr =['A相耐压前','B相耐压前','C相耐压前','A相耐压后','B相耐压后','C相耐压后','A相电压','B相电压','C相电压','A相频率','B相频率','C相频率','A相时间','B相时间','C相时间','A相结果','B相结果','C相结果']
        const arr2 = arr1.filter(ele => {
          for (let i = 0; i < arr.length; i++){
             if(ele.trialProjectName==arr[i]){
              return ele
             }
          }
        })
        this.array = setlistsort(arr2, arr)
        let arr3 = ['结论', '备注', '试验员', '审核人', '批准人']
        const arr4 = arr1.filter(ele => { 
          for (let i = 0; i < arr3.length; i++){
             if(ele.trialProjectName==arr3[i]){
              return ele
             }
          }
        })
        this.forterlist = arr4
        loading.close();
      }
    }
  }
};
</script>

<style scoped>
*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
 .shangxia{
      height: 500px;
      overflow: auto;
      border-bottom: 1px solid #ccc;
      
      .twobox{
        padding: 15px 0;
        .texth{
              font-size: 18px;
              font-weight: bold;
              color: #323232;
            }
            .shiyanshuju{
              width: 100%;
              margin-top: 20px;
              border: 1px solid #ccc;
              .header{
                display: flex;
                background-color: #f1f1f1;
                .neirong{
                  width: 40%;
                  height: 50px;
                  line-height: 50px;
                  text-align: center;
                }
                .xiang{
                  width: 20%;
                  height: 50px;
                  line-height: 50px;
                  text-align: center;
                  border-left: 1px solid #ccc;
                }
              }
              .bodyleft{
                width: 40%;
                background-color: #f1f1f1;
                height: 300px;
                .toop{
                  display: flex;
                  .zuo{
                    width: 50%;
                    height: 100px;
                    line-height: 100px;
                    text-align: center;
                    border-bottom: 1px solid #ccc;
                    border-top: 1px solid #ccc;
                  }
                  .you{
                    width: 50%;
                    .little{
                      height: 50px;
                      line-height: 50px;
                      text-align: center;
                      border-top: 1px solid #ccc;
                      border-left: 1px solid #ccc;
                    }
                  }
                }
                .zhongjian{
                  display: flex;
                  .jiaoliu{
                    width: 50%;
                    height: 150px;
                    line-height: 150px;
                    text-align: center;
                  }
                  .time{
                    width: 50%;
                    .xiao{
                      height: 50px;
                      line-height: 50px;
                      text-align: center;
                      border-top: 1px solid #ccc;
                      border-left: 1px solid #ccc;
                    }
                  }
                }
                .dibu{
                  height: 50px;
                  line-height: 50px;
                  text-align: center;
                  border-top: 1px solid #ccc;
                }
              }
              .xunhuan{
                .lillle{
                  width: 33.3333%;
                height: 50px;
                line-height: 50px;
                text-align: center;
                border-top: 1px solid #ccc;
                border-left: 1px solid #ccc;
                }

              }
            }
            .foorterxunhuan{
              margin-top: 30px;
              width: 100%;
              display: flex;
              flex-wrap: wrap;
               ::v-deep .el-form-item__label{
                font-size: 18px;
                  color: #323232;
                  font-weight: bold;
               }
              .inputbox{
                margin-bottom: 20px;
                width: 40%;
                .text{
                  font-size: 18px;
                  color: #323232;
                  font-weight: bold;
                }
              }
            }
        .threebox{
          padding: 10px;
            .bluebgc{
              display: inline-block;
              width: 5px;
              height: 16px;
              background-color: #187cf5;
              margin-right: 10px;
              border-radius: 3px;
              vertical-align: middle;
            }
            .bluetext{
              display: inline-block;
              vertical-align: middle;
              font-size: 18px;
              color: #323232;
            }
        }
      }
    }
.clearfix::after {
  content: "";
  clear: both;
  display: table;
  .bigwaiwei{
    width: 100%;
    .bgc{
      background-color: #f1f1f1;
    }
    .header{
      display: flex;
      .widthfour{
        width: 25%;
        height: 50px;
        text-align: center;
        line-height: 50px;
      }
    }
    .footer{
      display: flex;
      .footleft{
        width: 25%;
      }
    }
  }
}
::v-deep .el-form-item{
  display: flex;
  margin-right: 10px;
}
::v-deep .el-form-item__content{
  flex:1;
}
</style>